from race.Player import *
import logging.config
from wowThread.threadJob import *
from pynput.keyboard import Key
from pynput.mouse import Controller
import math

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")

class cloudDesktop(Player):
    # 界面上选择了12345，那个下拉选项
    def on_keyboard_press_son_before_thread(self, key):
        log.debug("on_keyboard_press_son_before_thread 1:进入了函数")
        # 有些按键是直接终止别人的，继续自己的，有些不是这样的，因此要区别对待【排列组合，情况非常多】/【也要超级符合每个职业的操作习惯】
        if key in (
                Key.f1, Key.f2, Key.f3, Key.f4, Key.f5, Key.f6, Key.f7, Key.f8, Key.f9, Key.f10, Key.f11,
                Key.f12):
            pass
        elif key == Key.enter:
            pass
        elif key == Key.space:
            pass
        elif key == Key.alt_l:
            pass
        elif key == Key.ctrl_l:
            pass
        elif key == Key.caps_lock:
            pass
        elif key == Key.shift_l:
            pass
        elif key.char == 'a':
            # 不终止别人，后面让只允许一个线程执行的逻辑来顺序排
            # ★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|
            # 并行并发执行的折中方案【通过触发其他按键，这样的好处是线程池统一管理了】
            pass
        elif key.char == 'z':
            pass
        elif key.char == 'q':
            pass
        elif key.char == 'w':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'r':
            # 终止掉别人
            # interruptAllByForce()
            pass
        elif key.char == 'g':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'x':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'v':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'h':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'c':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'e':
            pass
        elif key.char == 's':
            pass
        elif key.char == 'd':
            pass
        elif key.char == 'f':
            pass
        elif key.char == 'b':
            pass
        return

    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.startScheduler1()
        return

    def CallBackScheduler1(self):
        mouse = Controller()

        while self.ui.stopLoop == False:
            mouse.position = (0, 0)
            sleep(3)
            # 模拟云桌面的功能，避免被踢下线
            self.click(self.kb, 'e', 1)
            mouse.position = (200, 200)
            # 绘制外圆
            x = 420
            y = 520
            radius = 100  # 圆半径
            min_angle = 0
            min_angle = 0  # 每次循环角度计算
            max_angle = 360  # 最大角度
            spacing = 40  # 三角形的角度 可调整
            mouse.position = (x + radius, y)
            while min_angle <= max_angle and self.ui.stopLoop == False:
                # 角度计算
                min_angle += spacing

                # x,y 绝对坐标计算
                x2 = ('%.0f' % (x + radius * math.cos(min_angle * math.pi / 180)))
                y2 = ('%.0f' % (y + radius * math.sin(min_angle * math.pi / 180)))

                # 绝对坐标移动鼠标
                mouse.position = (int(x2), int(y2))
                sleep(1)

                if (max_angle - min_angle) < 80:
                    break
            sleep(10)
            self.click(self.kb, 'd', 1)
        pass

    def z(self):
        # 恶魔术士
        self.ui.stopLoop = True
        return